package com.imCode.web;

import com.sun.org.apache.xpath.internal.axes.IteratorPool;
import sun.text.resources.BreakIteratorInfo;
import sun.text.resources.cldr.pa.FormatData_pa;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

/**
 * Created by GO FOR IT on 2020/4/14.
 */
public class initialServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
//        System.out.println(request.getRequestURI());
//        System.out.println(request.getRequestURL());
//        System.out.println(request.getMethod());
//        System.out.println(request.getRemoteHost());
//        System.out.println(request.getRemotePort());
//        System.out.println(request.getLocalPort());
//        System.out.println(request.getQueryString());

//        //1、获取单个参数
//        String name = request.getParameter("name");
//
//        //2、获取多个参数
//        Map<String, String[]> parameterMap = request.getParameterMap();
//        for (String key:parameterMap.keySet()){
//            String[] strings = parameterMap.get(key);
//            System.out.println(key +":"+ Arrays.toString(strings));
//        }
//        //3、
//        String[] names = request.getParameterValues("name");
//        System.out.println(Arrays.toString(names));


        String name = request.getParameter("name");
        System.out.println(name);

        response.getWriter().print("hello" + name);
    }
}
